package com.bauer.module.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author ：rui.wei
 * @Date ：Created in 18:45 2019/9/19
 * @Description：
 */
public class PhoneUtils {


    public static boolean isPhone(String phone) {
        if (phone == null) {
            return false;
        }
        String regex = "^1[0-9]{10}$";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(phone);
        return m.matches();
    }

    public static String encodePhone(String phone) {
        if (phone == null) {
            return null;
        }
        return phone.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
    }

}
